package com.xs.bookspoststation.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBHelperUser extends SQLiteOpenHelper {

    private static final String DATA_NAME = "books_station.db";
    private static final int VERSION = 1;

    /**
     * name: 想要建立数据库的名字
     * factory:null
     * version:版本1
     */
    public DBHelperUser(Context context, String name, SQLiteDatabase.CursorFactory factory,int version){
        super(context,DATA_NAME,null,VERSION);
    }

    /**
     * 程序运行建立数据库，只运行一次
     * @param db
     */
    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql = "create table book_user(_id integer primary key autoincrement," +
                "username varchar(10),userpwd varchar(20),userphone varchar(10), " +
                "usersex varchar(20),userhobby varchar(20),usereducation varchar(20),userfullname varchar(10), " +
                "useremail varchar(20),userprovince varchar(20),userschool varchar(20))";
        db.execSQL(sql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
